<?php
/**
 * Permission
 *
 * @author fusq
 */
class Permission {    
    public static function getAllPermissions(){
        $translate = Zend_Registry::get('Zend_Translate');
        $permissions = array(
            1 => $translate->_('readUser'),
            2 => $translate->_('createUser'),
            3 => $translate->_('updateUser'),
            4 => $translate->_('deleteUser'),
         /* 5 => $translate->_('readDep'),
            6 => $translate->_('createDep'),
            7 => $translate->_('updateDep'),
            8 => $translate->_('deleteDep'), */    
            9 => $translate->_('readCategory'),
            10 => $translate->_('createCategory'),
            11 => $translate->_('updateCategory'),
            12 => $translate->_('deleteCategory'),    
          /*13 => $translate->_('readSetting'),
            14 => $translate->_('updateSetting'),     
            15 => $translate->_('readTriDash'),
            16 => $translate->_('readCusDash'),    
            17 => $translate->_('readSalesDash'),
            18 => $translate->_('readProDash'),  
            19 => $translate->_('readMakDash'),      
            20 => $translate->_('readTriReport'),    
            21 => $translate->_('createTriReport'),
            22 => $translate->_('updateTriReport'),  
            23 => $translate->_('deleteTriReport'),     
            24 => $translate->_('readCusReport'),    
            25 => $translate->_('createCusReport'),
            26 => $translate->_('updateCusReport'),  
            27 => $translate->_('deleteCusReport'),         
            28 => $translate->_('readSalesReport'),    
            29 => $translate->_('createSalesReport'),
            30 => $translate->_('updateSalesReport'),  
            31 => $translate->_('deleteSalesReport'),       
            32 => $translate->_('readProReport'),    
            33 => $translate->_('createProReport'),
            34 => $translate->_('updateProReport'),  
            35 => $translate->_('deleteProReport'),   
            36 => $translate->_('readMarReport'),    
            37 => $translate->_('createMarReport'),
            38 => $translate->_('updateMarReport'),  
            39 => $translate->_('deleteMarReport'),   */  
            40 => $translate->_('readOrder'),    
         //   41 => $translate->_('createOrder'),
            42 => $translate->_('updateOrder'),  
            43 => $translate->_('deleteOrder'),      
            44 => $translate->_('readProduct'),
            45 => $translate->_('createProduct'),
            46 => $translate->_('updateProduct'),
            47 => $translate->_('deleteProduct'),
            48 => $translate->_('readRole'),
            49 => $translate->_('createRole'),
            50 => $translate->_('updateRole'),
            51 => $translate->_('deleteRole'),
          /*52 => $translate->_('readPurPrice'),
            53 => $translate->_('updatePurPrice'),
            54 => $translate->_('readCostPrice'),
            55 => $translate->_('updateCostPrice'),
            56 => $translate->_('updateListPrice'),
            57 => $translate->_('readInventory'),
            58 => $translate->_('updateInventory'),*/
            59 => $translate->_('readCustomer'),
         //   60 => $translate->_('createCustomer'),
            61 => $translate->_('updateCustomer'),
            62 => $translate->_('deleteCustomer'),
            63 => $translate->_('readCoupon'),
            64 => $translate->_('createCoupon'),
            65 => $translate->_('updateCoupon'),
            66 => $translate->_('deleteCoupon'),
   /*       67 => $translate->_('readCredit'),
            68 => $translate->_('createCredit'),
            69 => $translate->_('updateCredit'),
            70 => $translate->_('deleteCredit'),
            71 => $translate->_('readEmailMar'),
            72 => $translate->_('createEmailMar'),
            73 => $translate->_('updateEmailMar'),
            74 => $translate->_('deleteEmailMar'),
            75 => $translate->_('readAffiliateMar'),
            76 => $translate->_('createAffiliateMar'),
            77 => $translate->_('updateAffiliateMar'),
            78 => $translate->_('deleteAffiliateMar'),
            79 => $translate->_('readMarkMapping'),
            80 => $translate->_('createMarkMapping'),
            81 => $translate->_('updateMarkMapping'),
            82 => $translate->_('deleteMarkMapping'),
            83 => $translate->_('readEmailTemplate'),
            84 => $translate->_('createEmailTemplate'),
            85 => $translate->_('updateEmailTemplate'),
            86 => $translate->_('deleteEmailTemplate'),
            87 => $translate->_('readFeaturePage'),
            88 => $translate->_('createFeaturePage'),
            89 => $translate->_('updateFeaturePage'),
            90 => $translate->_('deleteFeaturePage'),*/
            91 => $translate->_('readMetadata'),
            92 => $translate->_('createMetadata'),
            93 => $translate->_('updateMetadata'),
            94 => $translate->_('deleteMetadata'),
            95 => $translate->_('readMetadataSet'),
            96 => $translate->_('createMetadataSet'),
            97 => $translate->_('updateMetadataSet'),
            98 => $translate->_('deleteMetadataSet'),
            99 => $translate->_('readQueryReply'),
           100 => $translate->_('createQueryReply'),
           101 => $translate->_('updateQueryReply'),
           102 => $translate->_('deleteQueryReply'),
           103 => $translate->_('viewWithdraw'),
           104 => $translate->_('addWithdraw'),
           105 => $translate->_('deleteWithdraw'),
           106 => $translate->_('manageWithdraw'),
        //   107 => $translate->_('exportWithdraw'),
           108 => $translate->_('viewSupplement'),
           109 => $translate->_('addSupplement'),
           110 => $translate->_('deleteSupplement'),
           111 => $translate->_('manageSupplement'),
       //    112 => $translate->_('exportSupplement'),   
           113 => $translate->_('viewAgentApplay'),  
           114 => $translate->_('manageAgentApply'), 
           115 => $translate->_('deleteAgentApply'),
           116 => $translate->_('viewCampus'),
           117 => $translate->_('createCampus'),
           118 => $translate->_('updateCampus'),
           119 => $translate->_('deleteCampus'),
           120 => $translate->_('viewComment'), 
           121 => $translate->_('manageComment'),
           122 => $translate->_('deleteComment'),
           123 => $translate->_('viewApplyGiftLog'),
           124 => $translate->_('editApplyGiftLog'),
           125 => $translate->_('deleteApplyGiftLog'),
           126 => $translate->_('viewGift'),
           127 => $translate->_('addGift'),
           128 => $translate->_('updateGift'),
           129 => $translate->_('deleteGift'),
           130 => $translate->_('viewTradeLog'),
           131 => $translate->_('viewEmailSendingLog'),
           132 => $translate->_('deleteEmailSendingLog'),
           133 => $translate->_('massEmailing'),
           134 => $translate->_('viewSystemLog'),
           135 => $translate->_('deleteSystemLog'),
           136 => $translate->_('specialPromotion'),
           137 => $translate->_('addSpecialPromotion'),
           138 => $translate->_('editSpecialPromotion'),
           139 => $translate->_('deleteSpecialPromotion'),
           140 => $translate->_('specialNamePromotion'),
           141 => $translate->_('addSpecialNamePromotion'),
           142 => $translate->_('editSpecialNamePromotion'),
           143 => $translate->_('deleteSpecialNamePromotion'),
           144 => $translate->_('addComment')
        );
        return $permissions;
    }

     public static function getResourceActionByPermission($permission){
           $resourceAction = array(
                1 => array("admin",array("index","view")),
                2 => array("admin",array("add","subadd")),
                3 => array("admin",array("edit","subedit")),
                4 => array("admin",array("delete","deletesome")),
                5 => array("department",array("index")),
                6 => array("department",array("add","subadd")),
                7 => array("department",array("edit","subedit")),
                8 => array("department",array("delete","deletesome")),
                9 => array("category",array("index")),
                10 => array("category",array("add","subadd","test")),
                11 => array("category",array("edit","subedit")),
                12 => array("category",array("delete")),
                40 => array("order",array("index","getitems","list","search","detail","return")),
               // 41 => array("order",array("add","subpackage","addpackage","editpackage","updatepackage","subadd","edit","subedit","itemspanel","operationjournal","addjournal","deletejournal")),
                42 => array("order",array("add","subpackage","addpackage","editpackage","updatepackage","subadd","edit","subedit","itemspanel","operationjournal","addjournal","deletejournal",
                                          "process","cancelitem","subcancel","audit","subaudit","subrefund")),
                43 => array("order",array("delete","delpackage")),
                44 => array("product",array("uniquetitle","uniqueurltitle","index", "listitem", "search","searchrelate","searchitem")),
                45 => array("product",array("select","add","subadd","addattribute","additem","subadditems")),
                46 => array("product",array("edit","subedit","edititem","saveitem","edititemimage","editimageinfo","deleteimage","editimageattribute","issetdefaultimage","uploadimage","submitupload")),
                47 => array("product",array("deletesome","delitems","delete")),
                48 => array("acl",array("index","getrole")),
                49 => array("acl",array("addrole","addrolesubmit")),
                50 => array("acl",array("editrole","editrolesubmit")),
                51 => array("acl",array("deleterole","delete")),
                59 => array("customer",array("index","list","ajaxsearch","getlast","searchcustomer")),
            //  60 => array("customer",array("add","subadd","checknameunique","checkemailunique")),
                61 => array("customer",array("edit","subedit","checknameunique","checkemailunique","agentrelation",'checkagency',"paginatewishlist")),
                62 => array("customer",array("deletesome","delete")),
                120 => array("customer",array("usercommentslist")),
                121 => array("customer",array("editcomments","savecomments")),
                122 => array("customer",array("deletecomment")),
                144 => array("customer",array("addcomment")), 
                113 => array("agent",array("showapply")),
                114 => array("agent",array("applydetail","optionapply","renderambassador")),
                115 => array("agent",array("deloneapply")),
                116 => array("campus",array("index")),
                117 => array("campus",array("add","subadd")),
                118 => array("campus",array("edit","subedit")),
                119 => array("campus",array("delete")),
                13 => array("config",array("index")),
                14 => array("config",array("edit","subedit")),
        //        79 => array("marketingmapping",array("index")),
        //        80 => array("marketingmapping",array("add","subadd")),
        //        81 => array("marketingmapping",array("edit","subedit")),
        //        82 => array("marketingmapping",array("deletesome","delete")),
        //        83 => array("emailtemplate",array("index")),
        //        84 => array("emailtemplate",array("add","subadd")),
       //         85 => array("emailtemplate",array("edit","subedit")),
       //         86 => array("emailtemplate",array("deletesome","delete")),
      //          87 => array("featurepage",array("index")),
       //         88 => array("featurepage",array("add","subadd")),
      //          89 => array("featurepage",array("edit","subedit")),
      //          90 => array("featurepage",array("deletesome","delete")),
                63 => array("promotion",array("shipping","coupon","validationsame","saleprice")),
                64 => array("promotion",array("add","subadd","suncoupontype","productcoupon","subproductcoupon","ordercoupon","subordercoupon","salecoupon","subsalecoupon","addsaleprice","subsaleprice","editsaleprice","subeditsaleprice","coupontype","checkcodeunique","getcouponcode")),
                65 => array("promotion",array("editcoupon","subshipping","editproductcoupon","subeditproductcoupon","editordercoupon","subeditordercoupon","editsalecoupon","subeditsalecoupon","checkcodeunique","getcouponcode")),
                66 => array("promotion",array("deletesome","delete","deletesaleprice")),
                91 => array("metadata",array("index")),
                92 => array("metadata",array("add","subadd")),
                93 => array("metadata",array("edit","subedit")),
                94 => array("metadata",array("delete")),
                95 => array("set",array("index","searchrelate","gettreexml")),
                96 => array("set",array("add","subadd","addset","addgroup" ,"addmetadata","subaddset","subaddgroup","subaddmetadata")),
                97 => array("set",array("edit","subedit","editset","editgroup","editmetadata","subeditset","subeditgroup","subeditmetadata")),
                98 => array("set",array("deleteset","deletegroup","deletemetadata")),
                99 => array("consult",array("index")),
               100 => array("consult",array("add","subadd")),
               101 => array("consult",array("edit","subedit")),
               102 => array("consult",array("delete")),
               103 => array("withdraw",array("searchline","searchlinewait","searchoffline","searchofflinewait")),
               104 => array("withdraw",array("add","subadd")),
               105 => array("withdraw",array("deleteline")),
               106 => array("withdraw",array("online","surewithdraw","waitcheckonline","rejectonline","overpassonline","offline","surewithdrawoffline","waitcheckoffline","rejectoffline","overpassoffline")),
               108 => array("supplement",array("online","offline","index")),
               109 => array("supplement",array("add","subadd")),
               111 => array("supplement",array("view","pending","deny","approved")),
               123 => array("applygiftlog",array("index")),
               124 => array("applygiftlog",array("edit","subedit")),
               125 => array("applygiftlog",array("delete")),
               126 => array("gift",array("index")),
               127 => array("gift",array("add","subadd")),
               128 => array("gift",array("edit","subedit")),
               129 => array("gift",array("delete")),
               130 => array("tradelog",array("index")),
               131 => array("emaillog",array("index","view")),
               132 => array("emaillog",array("delete")),
               133 => array("email",array("index","send")),
               134 => array("systemlog",array("index","view")),
               135 => array("systemlog",array("delete")),
               136 => array("promotion",array("special", "subspecial")),
               137 => array("promotion",array("addspecial")),
               138 => array("promotion",array("editspecial")),
               139 => array("promotion",array("deletespecial")),
               140 => array("promotion",array("specialname", "subspecialname")),
               141 => array("promotion",array("addspecialname")),
               142 => array("promotion",array("editspecialname")),
               143 => array("promotion",array("deletespecialname"))              
           );
           return isset($resourceAction[$permission]) ? $resourceAction[$permission] : null;
     }
}
